Python for MATLAB Development by Albert Danial

Python for MATLAB Development by Albert Danial
Author: Albert Danial
Language: eng
Format: epub
ISBN: 9781484272237
Publisher: Apress

With our Circle class defined, we’ll make objects a and b which are instances of Circle :MATLAB:

Python:

>> a = Circle(0,0,10);

>> b = Circle(1,2,4);

>> b.y

2

>> a.area()

314.1592

In : a = Circle(0,0,10)

In : b = Circle(1,2,4)

In : b.y

Out: 2

In : a.area()

Out: 314.1592

The act of creating an object from a class, as with a = Circle(0,0,10), causes the class’s constructor method—a function with the same name as the class in MATLAB, and the function __init__() in Python— to be called with the provided arguments.